<template>
<slot :controller="controller" :store="store" :model="model" :viewName="embedView.embedViewName" :actions="{ handleAdd, handleRemove, handleCtrlInit, handleCtrlAction, handleCtrlMounted }">
        <AppMultiEditViewPanel
            v-bind="$attrs"
            :id="controlID"
            :items="store.data"
            :class="classNames"
            :panelStyle="panelStyle"
            :viewName="embedView.embedViewName"
            @add="handleAdd"
            @remove="handleRemove">
            <template #default="{ context, viewParams, itemId }">
                <IBIZOrderDetailSEditView9
                    :context="context"
                    :viewParams="viewParams"
                    openType="EMBED"
                    class="view-container2"
                    @view-init="(name: string, data: IViewAbility) => { handleCtrlInit(controller, name+itemId, data); }"
                    @view-action="(name: string, action: string, data: IParam[]) => { handleCtrlAction(controller, name+itemId, action, data); }"
                    @view-mounted="(name: string, data: IParam) => { handleCtrlMounted(controller, name+itemId, data); }">
                </IBIZOrderDetailSEditView9>
            </template>
        </AppMultiEditViewPanel>
</slot> 
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@MULTIEDITVIEWPANEL}}-multi-editview-panel/{{spinalCase ctrl.codeName}}-multi-editview-panel-base.vue.hbs生成
import { AppMultiEditViewPanel } from '@components/widgets/multi-editview-panel';
import { useProps, useBasic, useAction, useController } from './main-multi-editview-panel-hook';
import { MultiEditViewPanelActionType, IMultiEditViewPanelAbility, IMultiEditViewPanelStore, IParam, IViewLogicInput, IViewAbility } from "@/core/interface";

// 输入参数
const props = defineProps(useProps());

// 基础数据
const { controlID, getClassNames, model ,useNavParamsBind, useEventBind, handleActionClick, handleComponentAction,handleCtrlInit,handleCtrlAction,handleCtrlMounted } = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: MultiEditViewPanelActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: IMultiEditViewPanelAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
//  部件样式名
const classNames = computed(() => {
  return getClassNames(props);
});

//  多编辑面板部件控制器
const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: IMultiEditViewPanelStore = controller.getStore();

const  { handleAdd, handleRemove } = useAction(controller);

onMounted(() => {
    controller.ctrlMounted();
});
onUnmounted(() => {
    controller.ctrlDestroy();
})

</script>